
const express = require('express');
const os = require('os');
const path = require('path')
const app = express();
function getIPAdress() {
  var interfaces = os.networkInterfaces();
  for (var devName in interfaces) {
    var iface = interfaces[devName];
    for (var i = 0; i < iface.length; i++) {
      var alias = iface[i];
      if (alias.family === 4 && alias.address !== '127.0.0.1' && !alias.internal) {
        return alias.address;
      }
    }
  }
}

const server = app.listen(3000, function () {
  const host = getIPAdress()
  const port = server.address().port
  console.log("express 实现文件托管 http://%s:%s", host, port)
})

app.use('/', express.static(path.join(__dirname, 'build')))
app.use('/static', express.static(path.join(__dirname, 'static')))



